package per.yan.learn.navplugin

import com.android.build.gradle.BaseExtension
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.ApplicationPlugin
import per.yan.learn.navpluginruntime.NavData
import per.yan.learn.navpluginruntime.NavDestination

class NavPlugin : Plugin<Project>{
    override fun apply(project: Project) {

        print("NavPlugin apply ...")
        val appPlugin = project.plugins.findPlugin(ApplicationPlugin::class.java)

        assert(appPlugin == null){
            throw GradleException("NavPlugin 只能部署到 applocation 插件所在的项目库中.....")

        }

        val extensions = project.extensions.findByType(BaseExtension::class.java)


        extensions?.registerTransform(NavTransform(project) )
    }
}

